home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_081 / icon / amiga.doc < prev    next >
Text File  |  1992-05-06  |  22KB  |  576 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                       Version 6.0 of Icon for the Amiga
  8.  
  9.                                Scott Ballantyne
  10.  
  11.  
  12.  
  13.  
  14.     1. Introduction
  15.  
  16.        Version 6 of Icon for the Amiga should run on any Amiga with
  17.     at least 512k of memory and running Kickstart Version 1.2
  18.     Due to the intense memory requirements of Icon, more memory is
  19.     recommended, however, with few exceptions, you should be able to
  20.     handle most programming tasks on a 512k box.
  21.  
  22.  
  23.        The Amiga implementation of Icon is the work of Scott Ballantyne
  24.     and Gary Sarf, and may be freely distributed on the usual 'use
  25.     at your own risk' basis.  It is based on the public domain version
  26.     of Icon from the University of Arizona.
  27.  
  28.        The University of Arizona has released an upgraded version of
  29.     Icon (V6.3), which fixes a few bugs in Version 6.0.  We hope to
  30.     make this available on the Amiga in a few months.  We will also
  31.     be releasing the source code for Amiga Icon at that time.
  32.     Meanwhile, 6.0 is very usable as it is.  Version 6.3 for the Amiga
  33.     will also be using the arp.library, and so should be somewhat smaller.
  34.  
  35.        If you encounter any bugs or problems I would like to hear
  36.     about them:
  37.  
  38.     BIX: SDB
  39.     CIS: 70066,603
  40.  
  41.     And elsewhere...
  42.  
  43.     2. Documentation
  44.  
  45.        The basic reference for the Icon programming language is the
  46.     book
  47.  
  48.          The Icon Programming Language, Ralph E. Griswold and Madge
  49.          T. Griswold, Prentice-Hall, Inc., Englewood Cliffs, New Jer-
  50.          sey, 1983. 313 pages. ISBN 0-13-449777-5. $25.95.
  51.  
  52.     This book is available in many college bookstores or can be
  53.     ordered through any bookstore that handles special orders or by
  54.     telephone directly from Prentice-Hall: (201) 767-9520.
  55.  
  56.        A brief overview of Icon is contained in technical report TR
  57.     83-3 [1] (overview.doc on the distribution diskette). Features
  58.     that have been added to Icon since the book was written are
  59.     described in TR 86-10b [2] (version6.doc on the distribution
  60.     diskette).  These technical reports, together with this document
  61.     (Amiga.doc on this diskette), provide enough information to write
  62.     simple Icon programs, but persons who are going to use Icon seri-
  63.     ously will need the book.
  64.  
  65.  
  66.     3. Installing Amiga Icon
  67.  
  68.        There are five executable binary files needed to run Icon:
  69.  
  70.             Icont   command processor
  71.             Itran   translator
  72.             Ilink   linker
  73.             Iconx   run-time system
  74.         ixhdr   start-up code
  75.  
  76.        Icont should be located on a place in your Path specification, while
  77.     the remaining files may be placed wherever you like, however, you
  78.     need to tell Icon where they are by making the following Assigns:
  79.  
  80.     Assign ICONX:    location of Iconx
  81.     Assign ICONT:    location of Icont
  82.     Assign ILINK:   location of Ilink
  83.     Assign ITRAN:    location of Itran
  84.     Assign HEAD:    location of ixhdr
  85.  
  86.     If you start to get requesters which say, for example, "Please Insert
  87.     Volume ICONX: in any drive", it is because you forgot to make these
  88.     Assigns.  The easiest way to do this is to use a batchfile, or the
  89.     startup-sequence file if you boot to an Icon disk.
  90.  
  91.     You will also need the Set program, which is included on this diskette,
  92.     and is the work of Thomas Rokicki of Radical Eye Software.  The MANX Set
  93.     may also be used, but the two versions of Set (the Rokicki Set and the
  94.     MANX set) should not be mixed.  If you are intending to use floating
  95.     point math, then you will also need the mathieeedoubbas.library (as
  96.     supplied on 1.2 Workbench disks) in the LIBS: directory.
  97.  
  98.  
  99.     4. Running Amiga Icon - Basic Information
  100.  
  101.        Files containing Icon programs must have the extension .icn.
  102.     Such files should be plain text files (without line numbers or
  103.     other extraneous information).  The command processor icont runs
  104.     itran and ilink to produce an ``icode'' file that can be executed
  105.     by iconx.  For example, an Icon program in the file prog.icn is
  106.     translated and linked by
  107.  
  108.             1> icont prog.icn
  109.  
  110.     The result is an icode file with the name prog (with the exten-
  111.     sion removed).  This file can be run by simply typing it's name,
  112.     as though it were a binary machine code file, or by providing it
  113.     as an argument to the icon runtime system as:
  114.  
  115.             1> prog
  116.     or
  117.         1> iconx prog
  118.  
  119.     Alternatively, icont can be instructed to execute the program
  120.     after linking and translating by appending a -x to the command
  121.     line, as in
  122.  
  123.             icont prog.icn -x
  124.  
  125.     In this case the file prog also is left and can be run subse-
  126.     quently simply by typing it's name at the CLI prompt.
  127.  
  128.        If you find you are having difficulty due to memory constraints,
  129.     there are various environment variables used by Icon which you may
  130.     use to ''fine-tune'' your version. Section 6 has more information
  131.     about other aspects of running Icon.
  132.  
  133.  
  134.     5. Testing the Installation
  135.  
  136.        There are a few programs on the distribution diskette that may
  137.     be used for testing the installation and getting a feel for run-
  138.     ning Icon:
  139.  
  140.     hello.icn   This program prints the Icon version number, time,
  141.                 and date. Run this test as
  142.  
  143.                         1> icont hello.icn
  144.                         1> hello
  145.  
  146.                 Note that this can be done in one step with
  147.  
  148.                         1> icont hello.icn -x
  149.  
  150.  
  151.     cross.icn   This program prints all the ways that two words
  152.                 intersect in a common character. The file cross.dat
  153.                 contains typical data. Run this test as
  154.  
  155.                         1> icont cross.icn
  156.             1> cross <cross.dat
  157.  
  158.  
  159.  
  160.     meander.icn This program prints the ``meandering strings'' that
  161.                 contain all subsequences of a specified length from a
  162.                 given set of characters. Run this test as
  163.  
  164.                         1> icont meander.icn 
  165.             1> meander <meander.dat
  166.  
  167.  
  168.     roman.icn   This program converts Arabic numerals to Roman
  169.                 numerals. Run this test as
  170.  
  171.                         1> icont roman.icn -x
  172.  
  173.                 and provide some Arabic numbers from your console.  Hit
  174.         CNTRL-\ when you want to terminate.
  175.  
  176.     wordcnt.icn This program tabulates the number of occurrences of
  177.                 each word from the input file. Run this test as
  178.  
  179.                         1> icont wordcnt.icn
  180.             1> wordcnt <file
  181.  
  182.                 where file contains some text of interest. Caution:
  183.                 the tabulation is kept in memory; do not try to pro-
  184.                 cess a large file - unless you have a lot of memory!
  185.  
  186.     If these tests work, your installation is probably correct and
  187.     you should have a running version of Icon.  If you want to save
  188.     the output from any of these programs, you may redirect the output
  189.     as well, for example:
  190.     
  191.         1> wordcnt <file >outfile
  192.  
  193.     If there are other examples included, have fun with them!
  194.  
  195.     6. More on Running Icon
  196.  
  197.        For simple applications, the instructions for running Icon
  198.     given in Section 4 may be adequate. The icont command processor
  199.     supports a variety of options that may be useful in special
  200.     situations.  There also are several aspects of execution that can
  201.     be controlled with environment variables.  These are listed here.
  202.     Persons who are new to Icon may wish to skip this section on the
  203.     first reading but come back to it if they find the need for more
  204.     control over the translation and execution of Icon programs.
  205.  
  206.     6.1 Arguments
  207.  
  208.        Arguments can be passed to the Icon program by appending them
  209.     to the command line.  Such arguments are passed to the main pro-
  210.     cedure as a list of strings.  For example,
  211.  
  212.             1> prog text.dat log.dat
  213.  
  214.     runs the icode file prog, passing its main procedure a list of
  215.     two strings, "text.dat" and "log.dat".  The program also can be
  216.     translated, linked, and run with these arguments with a single
  217.     command line by putting the arguments after the -x:
  218.  
  219.             1> icont prog.icn -x text.dat log.dat
  220.  
  221.     These arguments might be the names of files that prog1.icn reads
  222.     from and writes to. The main procedure might begin as follows:
  223.  
  224.             procedure main(a)
  225.                in := open(a[1]) | stop("cannot open input file")
  226.                out := open(a[2],"w") | stop("cannot open output file")
  227.                            .
  228.                            .
  229.                            .
  230.  
  231.     See also the information about the processing of command-line
  232.     arguments given in Section 6.4.
  233.  
  234.     6.2 The Command Processor
  235.  
  236.        The command processor icont can accept several input files at
  237.     one time.  When several files are given, they are translated and
  238.     combined into a single icode file whose name is derived from the
  239.     name of the first file.  For example,
  240.  
  241.             icont prog1.icn prog2.icn
  242.  
  243.     translates and links the files prog1.icn and prog2.icn and pro-
  244.     duces one icode file, prog1.
  245.  
  246.        A name other than the default one for the icode file produced
  247.     by the Icon linker can be specified by using the -o option, fol-
  248.     lowed by the desired name. For example,
  249.  
  250.             icont -o probe prog.icn
  251.  
  252.     produces the icode file named probe rather than prog.
  253.  
  254.        If the -c option is given to icont, only translation is per-
  255.     formed and intermediate ``ucode'' files with the extensions .u1
  256.     and .u2 are kept.  For example,
  257.  
  258.             icont -c prog1.icn
  259.  
  260.     leaves prog1.u1 and prog1.u2, instead of linking them to produce
  261.     prog1. (The ucode files are deleted unless the -c option is
  262.     used.) These ucode files can be used in a subsequent icont com-
  263.     mand by using the .u1 name. This avoids having to translate the
  264.     .icn file again. For example,
  265.  
  266.             icont prog2.icn prog1.u1
  267.  
  268.     translates prog2.icn and links the result with the ucode files
  269.     from a previous translation of prog1.icn. Note that only the .u1
  270.     name is given. Ucode files also can be added to a program when it
  271.     is linked by using the link declaration in an Icon source program
  272.     as described in [2].
  273.  
  274.        It is worth noting that icont only controls the execution of
  275.     the other components of the Icon system. For example,
  276.  
  277.             icont prog.icn -x
  278.  
  279.     is equivalent to
  280.  
  281.             itran prog.icn
  282.             ilink prog.u1
  283.             iconx prog
  284.  
  285.     The Amiga version of Icont has a -v option, which will display the
  286.     command lines it is executing.  This can be useful if you are
  287.     curious about exactly what information Icont is sending the various
  288.     subsystems.
  289.  
  290.        Icon source programs may be read from standard input.  The
  291.     argument - signifies the use of standard input as a source file.
  292.     In this case, the ucode files are named stdin.u1 and stdin.u2 and
  293.     the icode file is named stdin.  You indicate that you are finished
  294.     with the text entry by typing CNTRL-\ (the Amiga standard EOF indicator).
  295.  
  296.        The informative messages from the translator and linker can be
  297.     suppressed by using the -s option.  Normally, both informative
  298.     messages and error messages are sent to standard error output.
  299.  
  300.        The -t option causes &trace to have an initial value of -1
  301.     when the program is executed.  Normally, &trace has an initial
  302.     value of 0.
  303.  
  304.        The option -u causes warning messages to be issued for unde-
  305.     clared identifiers in the program.  The warnings are issued dur-
  306.     ing the linking phase.
  307.  
  308.        Icon has several tables related to the translation and linking
  309.     of programs.  These tables are large enough for most programs,
  310.     but translation or linking is terminated with an error message,
  311.     indicating the offending table, if there is not enough room.  If
  312.     this happens, larger table sizes can be specified by using the -S
  313.     option. This option has the form -S[cfgilrstCL]n, where the
  314.     letter following the S specifies the table and n is the number of
  315.     storage units to allocate for the table.
  316.  
  317.  
  318.          c  constant table          100
  319.          f  field table             100
  320.          g  global symbol table     200
  321.          i  identifier table        500
  322.          l  local symbol table      100
  323.          r  record table            100
  324.          s  string space         15,000
  325.          t  tree space           15,000
  326.          C  code buffer          20,000
  327.          L  labels                  500
  328.  
  329.     The units depend on the table involved, but the default values
  330.     can be used as guides for appropriate settings of -S options
  331.     without knowing the units.  For example,
  332.  
  333.             icont -Sc200 -Sg600 prog.icn
  334.  
  335.     translates and links prog.icn with twice the constant table space
  336.     and three times the global symbol table space that ordinarily
  337.     would be provided.
  338.  
  339.     6.3 Environment Variables
  340.  
  341.        When an Icon program is executed, several environment vari-
  342.     ables are examined to determine certain execution parameters.
  343.     You establish the values of environment variables by using Set,
  344.     which should be included with the Amiga Icon distribution
  345.     package.  Syntax is
  346.  
  347.     set STRING=VALUE
  348.  
  349.    VALUE can be anything, numeric or string data, that is required
  350.    by Icon.  Generally, the Icon environment variables require numbers.
  351.    When setting a numeric environment variable do not include commas
  352.    or other formatting characters - digits only.
  353.  
  354.    If you type Set, by itself, with no arguments, then it will display
  355.    a list of all currently defined environment variables, along with their
  356.    values.
  357.  
  358.    Finally, to remove an environment variable from memory, just type
  359.  
  360.         Set STRING=
  361.  
  362.    With nothing following the '=' sign, and this variable will be removed.
  363.  
  364.        Environment variables are particularly useful in adjusting
  365.     Icon's storage requirements. This may be necessary if your com-
  366.     puter does not have enough memory to run Icon as configured or for programs
  367.     that have unusual demands for a particular kind of data.  Partic-
  368.     ular care should be taken when changing default sizes: unreason-
  369.     able values may cause Icon to malfunction.
  370.  
  371.        The variables that affect the execution of Icon are:
  372.  
  373.        TRACE initializes the value of &trace.  If this variable has a
  374.     value, it overrides the translation-time -t option.
  375.  
  376.        NBUFS determines the number of i/o buffers used for files.
  377.     When a file is opened, it is assigned an i/o buffer if one is
  378.     available and the file is not the console.  If no buffer is
  379.     available, the file is not buffered.  &input, &output, and
  380.     &errout are buffered if buffers are available.  The defualt for
  381.     the Amiga implementation is 10.
  382.  
  383.        If NOERRBUF is set, &errout is not buffered.
  384.  
  385.        STRSIZE determines the initial size of the string space, in
  386.     bytes.  The string space grows if necessary, but it never
  387.     shrinks.  For the Amiga implementation of Icon, the default
  388.     value of STRSIZE is 51,200. If the amount of memory available for
  389.     running the Icon is small, the initial size of the string space
  390.     can be set to a smaller value, such as 10,000.
  391.  
  392.        HEAPSIZE determines the initial size of the allocated block
  393.     region, in bytes.  The heap grows if necessary, but it never
  394.     shrinks.  The default value of HEAPSIZE is 51,200.  If the amount
  395.     of memory available for running Icon is small, the initial size of
  396.     the allocated block region can be set to a smaller value, such as 10,000.
  397.  
  398.        COEXPSIZE determines the size, in words, of each co-expression
  399.     block.  The default value of COEXPSIZE is 2,000.
  400.  
  401.  
  402.        MSTKSIZE determines the size, in words, of the main inter-
  403.     preter stack. The default value of MSTKSIZE is 10,000.
  404.     The size of the main interpreter stack can be set to a smaller
  405.     value, such as 5,000. If the main interpreter stack is not large
  406.     enough, excessive recursion may lead to program termination with
  407.     a run-time error message.
  408.  
  409.        STATSIZE determines the size, in bytes, of the static region
  410.     in which co-expression blocks are allocated. The default value of
  411.     STATSIZE is 20,480.
  412.     If the amount of memory available for running Iconis small,
  413.     the size of the static region can be set to a small value, such
  414.     as 100, provided that co-expressions are not used.
  415.  
  416.        STATINCR determines the size of the increment used when the
  417.     static region is expanded.  The default increment is one-fourth
  418.     of the initial size of the static region.
  419.  
  420.     Icon on the Amiga allocates all it's memory from one big
  421.     heap.  Initially, Icon will attempt to grab the largest section
  422.     of contiguos memory it can find.  If you wish to limit the amount
  423.     of memory Icon will ask for, then you can set the the maximum amount
  424.     of memory Icon will ask for with the MAXMEM environment variable.
  425.     This variable should specify a value in Kbytes, thus MAXMEM=300
  426.     will limit the amount of memory Icon will request to 300k bytes.
  427.     Note that you may not get all the memory you ask for - Icon will
  428.     attempt to get the amount of memory you asked for, but if it is
  429.     not available, will ask for less.  You will not get an out of memory
  430.     error if this occurs.  Out of memory errors will occur only when
  431.     an Icon program needs more memory than Icon has available, and this
  432.     is determined as the program runs its course, not during the icon
  433.     system initialization.
  434.  
  435.     You can use the environment variable UFILES to establish where
  436.     icont will place the temporary .u? files.  By setting UFILES=RAM:,
  437.     these will be placed in the ram disk, greatly speeding up the linking
  438.     and translating phases of the process.
  439.  
  440.        Amiga Icon supports all the features of Version 6 of Icon,
  441.     with the following exceptions and additions:
  442.  
  443.  
  444.          o  Pipes are not supported. A file cannot be opened with the
  445.             ``p'' option.
  446.  
  447.  
  448.      o  The PATH environment variable is not used on the Amiga, instead,
  449.         the CLI path is searched, as set by the Path command.
  450.  
  451.          o  The IPATH environment string used by the Icon linker, is
  452.             supported as described in [2].  The separator between
  453.             paths is the bang ('!'). The current directory is always
  454.             searched. You should specify a ':' in volume names,
  455.         but you should not add a trailing '/' to path names.
  456.         For example:
  457.         
  458.             set IPATH=df1:!df1:Iconstuff!df1:icontstuff/bookstuff
  459.  
  460.         will cause the linker to examine the current directory for
  461.         linkable files, then the root directory of df1:, then Df1:Iconstuff,
  462.         then df1:iconstuff/bookstuff.
  463.  
  464.          o  All of the AmigaDOS logical devices can be used as files,
  465.             this provides a simple means to output to a window, by opening
  466.         a CON: or RAW: window.
  467.  
  468.          o  Trace output is sent to STDERR.
  469.  
  470.     The following functions have been added to Icon only for the Amiga version,
  471.     and should not be expected to be found on other versions:
  472.  
  473.  
  474.     o Translate(string) -- returns translated string, try:
  475.         Write(Translate("Hello big boy"))
  476.  
  477.     o Narrate(string, rate, pitch, mode, sex, volume, sampfreq, side)
  478.         You can simply do Narrate(Translate(string)) if you want
  479.         to accept the defaults, or you can set specific parameters:
  480.  
  481.         rate - rate of speaking -- 40 to 400, default is 150
  482.         pitch - pitch of voice -- 65 to 320. default is 110
  483.         mode - may be "natural" or "robotic", or you may use 0 or 1.
  484.             default is natural (0).
  485.         sex - may be "male" or "female", or you may use 0 or 1
  486.             default is male (0)
  487.         volume - loudness of voice -- 0 (silence) to 64, default is 64
  488.         sampref - sample frequency. 5000 to 28000, default is 22200
  489.         side - may be "both", "right" or "left", to set the speaker from
  490.             which the voice will come, default is "both".
  491.  
  492.         NOTE:  You will have to use MAXMEM to limit the amount of
  493.         memory initially grabbed by icon, or there will not be
  494.         enough room in memory for the translator and narrator when
  495.         you call these functions!
  496.  
  497.  
  498.     o Delay(timeout) - wait timeout ticks, 50 per second, returns #seconds
  499.                Delayed, defaults to 1 second.  You should use this
  500.                if you want a delay, instead of busy waiting.
  501.  
  502.     o DeleteFile(file) -- Delete a file.
  503.     o Rename(old, new) -- Rename files
  504.     o SetComment(file, string) -- Set a comment for file
  505.  
  506.     All of these functions use the Icon conventions as much as possible.
  507.  
  508.     The following functions are also extensions to Icon, but are common
  509.     enough across implementations that you can somewhat depend on them:
  510.  
  511. MATH:
  512.     exp(x)
  513.     log(x)
  514.     log10(x)
  515.     sqrt(x)
  516. TRIG:
  517.     sin(x)
  518.     cos(x)
  519.     tan(x)
  520.     acos(x)
  521.     asin(x)
  522.     atan(x)
  523.     atan2(x, y)
  524.     dtor(x)        # Convert degrees to radians
  525.     rtod(x)        # Radians to degrees
  526. FILES:
  527.     seek(file, offset, start) - aka C's fseek.
  528. GETENV:
  529.     getenv(s) - return contents of environment variable s
  530.  
  531.     6.4  Further details about running Icon programs.
  532.  
  533.     Icon does not actually produce machine code executable files.
  534.     What actually happens is that the linker (Ilink) writes an executable
  535.     file header (the program ixhdr, located in assigned directory HEAD:)
  536.     which then loads and runs Iconx (the run time system) passing itself
  537.     as an argument.  This appears complex, but is actually the way Icon
  538.     is handled on most systems - Icon compilers do not actually increase
  539.     execution speed by very much, but they do increase program size a
  540.     considerble amount.
  541.  
  542.     You may run Icon programs without taking advantage of this feature,
  543.     by simply passing the icon program name to Iconx.  Here are some examples:
  544.  
  545.     1> prog
  546.     can also be run as
  547.     1> Iconx prog
  548.  
  549.     1> prog arg1 arg2 arg3
  550.     can also be run as
  551.     1> Iconx prog arg1 arg2 arg3
  552.  
  553.     1> prog <infile >outfile arg1 arg2 arg3
  554.     can also be run as
  555.     1> Iconx <infile >outfile prog arg1 arg2 arg3
  556.  
  557.     (Note that order of the arguments in this last one!).
  558.  
  559.     Of course, in this case, Iconx must be in your search path, and the icon
  560.     program must have it's full name specified - the CLI path will not be
  561.     searched.
  562.  
  563.     Icon programs may be interrupted by using CNTRL-C.  However, the Icon
  564.     system will only check for the CNTRL-C when it is doing I/O, so if you
  565.     are stuck in an non I/O bound loop, well, it is time to reboot.
  566. ________________________________________________
  567.  
  568.     1.   R. E. Griswold, An Overview of the Icon Programming
  569.          Language, The Univ. of Arizona Tech. Rep. 83-3c, 1983,
  570.          Revised 1986.
  571.  
  572.     2.   R. E. Griswold, W. H. Mitchell and J. O'Bagy, Version 6 of
  573.          Icon, The Univ. of Arizona Tech. Rep. 86-10b, 1986.
  574.  
  575.  
  576.